<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.text.DateFormat"%>
<%@page import="com.sa.screencomputer.utils.Constants"%>
<%@page import="com.sa.screencomputer.screen.Img"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Screen</title>
</head>
<body>

	<%
		String url = request.getContextPath() + "/Action";
	%>

	<button type="button" onclick="javascript:window.location.href='/screencomputer/Action'">Refresh</button>
	&nbsp;&nbsp;
	<button type="button" onclick="javascript:window.location.href='/screencomputer/Action?action=delete'">Delete all</button>

	<%
		DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
	%>

	<%
		List<Img> filesDisplay = (List<Img>) request.getAttribute("filesDisplay");
		System.out.println(filesDisplay);
		if (filesDisplay != null) {
			for (Img file : filesDisplay) {
	%>

	<br>
	<%
	int width = (int)(file.getWidth() * Constants.COEF_IMAGE_1);
	int height = (int)(file.getHeight() * Constants.COEF_IMAGE_1);
	%>
	<img alt="" src="<%=request.getContextPath() + "/tmp/" + file.getName()%>"
		height="<%=height%>" width="<%=width%>">
	<br>
	<%
		}
		}
	%>
	<br><br>
	<b>Historique</b>
	<br>
	<table border="1">
	<%
		List<Img> filesUrl = (List<Img>) request.getAttribute("filesUrl");
		System.out.println(filesUrl);
		if (filesUrl != null) {
			for (Img file : filesUrl) {
	%>
		<tr>
			<td>
				<%
				int width = (int)(file.getWidth() * Constants.COEF_IMAGE_2);
				int height = (int)(file.getHeight() * Constants.COEF_IMAGE_2);
				%>
				<a href="javascript:window.showModalDialog('display.jsp?file=<%=file.getName()%>&width=<%=width-5%>&height=<%=height-5%>', null, 'dialogWidth:<%=width%>px; dialogHeight:<%=height%>px; center:yes; status=no; resizable=no; edge=raised');"><%=file.getName()%></a>
			</td>
			<td>
				<%=file.getSize()%>ko				
			</td>
			<td>
				<%=dateFormat.format(file.getDate())%>
			</td>
		</tr>
	<%
		}
		}
	%>
	</table>	
	
<br>

</body>
</html>